package login.servlet;

import login.dao.UserDao;
import login.dao.UserDaoImpl;
import login.daomain.User;
import org.apache.commons.beanutils.BeanUtils;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

/**
 * @Author Administrator
 * @Date 2020/6/2 14:15
 **/
@WebServlet("/Register")
public class RegisterServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        Map<String,String[]> map=req.getParameterMap();
        User user=new User();

        try {
            BeanUtils.populate(user,map);
        }catch (Exception e){
            e.printStackTrace();
        }
        UserDao dao=new UserDaoImpl();
        dao.zhuCe(user);


    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
